﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MedicalCare.EntityDefinitions.Entities;
using MedicalCare.Messages;

namespace MedicalCare.Translator
{
    public class UserInfoToUserMessage : IUserInfoToUserMessage
    {
        //Champion 2013/1/5
        public UserMessage Translate(UserEntity userInfo)
        {
                var address = new AddressMessage
                                  {
                                      Province = userInfo.Province,
                                      District = userInfo.District,
                                      AddressDetail = userInfo.AddressDetail,
                                      PostalCode = userInfo.PostalCode,
                                      City = userInfo.City
                                  };

                var userMessage = new UserMessage()
                                      {
                                          Success = true,
                                          // very important
                                          Id = userInfo.Id,
                                          Age = userInfo.Age,
                                          UserName = userInfo.Name,
                                          UserRoleCode = userInfo.RoleCode,
                                          Password = userInfo.Password,
                                          IDNumber = userInfo.IDNumber,
                                          Gender = userInfo.Gender,
                                          Mobile = userInfo.Mobile,
                                          Email = userInfo.Email,
                                          QQ = userInfo.QQ,
                                          Comment = userInfo.Comment,
                                          Valid = userInfo.Valid,
                                          UserAddress = address
                                      };
                return userMessage;
        }
    }
}
